const util = require('../../../../../utils/util.js');
const api = require('../../../../../config/api.js');
const app = getApp();
Page({
  data: {
    userID: 1,
    //成员列表
    userList: [1, 2, 2, 2, 3, 3, 0, 0, 0],
    //管理员列表
    adminList: [],
    //搜索框输入的文本
    searchText: '',
    //设置权限面板
    openSetTitle: false,
    //面板提示文字
    setTitleText: '11',
    //转换新圈主面板
    openSetHost: false,
  },
  onLoad: function (options) {
    var _this = this;
    var circleid = options.circleid;
    _this.setData({
      circleid: circleid
    })
    console.log(circleid)
  },
  onShow: function () {
    var _this = this
  },
  //拉伸顶部刷新
  onPullDownRefresh: function () {
    wx.stopPullDownRefresh();
  },
  //拉伸底部加载
  onReachBottom: function () {
    wx.stopPullDownRefresh();
  },
  //获取搜索框输入的文本
  inputText: function (e) {
    var _this = this
    var value = e.detail.value.replace(/\s+/g, '')
    _this.setData({
      searchText: value
    })
  },
  //设置和取消管理员，点评师
  setTitle: function (e) {
    var _this = this
    var type = e.target.dataset.type
    var index = e.target.dataset.index
    var arr = _this.data.userList
    if (type == "admin") {
      if (arr[index] == 2) {
        _this.setData({
          openSetTitle: true,
          setTitleText: "确定取消该成员管理员的资格吗？"
        })
      } else {
        wx.showToast({
          title: '设置成功',
          icon: 'success',
          duration: 2000
        })
      }
    }
    if (type == "remark") {
      if (arr[index] == 3) {
        _this.setData({
          openSetTitle: true,
          setTitleText: "确定取消该成员点评师的资格吗？"
        })
      } else {
        wx.showToast({
          title: '设置成功',
          icon: 'success',
          duration: 2000
        })
      }
    }
    if (type == "setHost") {
      _this.setData({
        openSetTitle: true,
        setTitleText: "设置后，等待对方确认，对方通过24小时后，方可成功转换。"
      })
    }
  },
  //设置新圈主面板
  setNewHost: function () {
    var _this = this
    var arr = _this.data.userList
    var info = []
    for (var i = 0; i < arr.length; i++) {
      if (arr[i] == 2) {
        info.push(arr[i])
      }
    }
    _this.setData({
      openSetHost: true,
      adminList: info
    })
  },
  //关闭设置新圈主面板
  closeSetHost: function () {
    var _this = this
    _this.setData({
      openSetHost: false
    })
  },
  //关闭面板
  closeMC: function () {
    var _this = this
    _this.setData({
      openSetTitle: false
    })
  },
})